package juc.thread.reentrantLock;

import java.util.concurrent.locks.ReentrantLock;

/*
* ReentrantLock-测试可重入
* */
public class Test1 {
   private static ReentrantLock lock = new ReentrantLock();
    public static void main(String[] args) {
        try {
            lock.lock();
            m1();
            System.out.println("enter main ...");
        } finally {
            lock.unlock();
        }
    }
    public static void m1(){
        try {
            lock.lock();
             m2();
            System.out.println("enter m1 ...");
        } finally {
            lock.unlock();
        }
    }
    public static void m2(){
        try {
            lock.lock();

            System.out.println("enter m2 ...");
        } finally {
            lock.unlock();
        }
    }
}
